from connector.DatabaseDriver import DatabaseDriver


def get_search_by_recipients(DatabaseDriver: DatabaseDriver, user_name: str):
    return DatabaseDriver.select_all("select * from courier where user_name = '{}'".format(user_name))


def get_search_by_recipient_phone(DatabaseDriver: DatabaseDriver, recipient_phone: str):
    return DatabaseDriver.select_all("select * from courier where recipient_phone = '{}'".format(recipient_phone))


def add_courier(DatabaseDriver: DatabaseDriver, user_name: str, courier_number: str, recipient_phone: str,
                recipient_address: str, sender: str, sender_phone: str, sender_address: str, courier_company: str):
    return DatabaseDriver.insert(
        "insert into courier (user_name,courier_number, recipient_phone, recipient_address,sender,sender_phone,sender_address,courier_company) values ('{}','{}','{}','{}','{}','{}','{}','{}')".format(
            user_name, courier_number, recipient_phone, recipient_address, sender, sender_phone, sender_address,
            courier_company))


def get_search_by_courier_number(DatabaseDriver: DatabaseDriver, courier_number: str):
    return DatabaseDriver.select_one("select * from courier where courier_number = '{}'".format(courier_number))


def out_courier_by_administrator(DatabaseDriver: DatabaseDriver, courier_number: str):
    return DatabaseDriver.delete("delete from courier where courier_number = '{}'".format(courier_number))
